﻿#pragma once
#include <memory>
#include <string>
#include <vector>
#include "../../../Common/D3DUtil.h"
#include "../../../Common/GameTimer.h"
#include "../../../Common/d3dx12.h"
#include "../../../Common/DDSTextureLoader.h"
#include "../../../Common/GeometryGenerator.h"
#include "../FrameResource.h"

using namespace std;
using namespace Microsoft::WRL;

class Pass
{
public:
    Pass();
    ~Pass() = default;
public:
    virtual void BuildRenderItems(std::vector<std::unique_ptr<RenderItem>>& allRitems,UINT& lastObjIndex) = 0;
    
    virtual void BuildPSOs(
        ID3D12Device* device,
        DXGI_FORMAT BackBufferFormat,
        DXGI_FORMAT DepthStencilFormat,
        bool _4xMsaaState,
        UINT _4xMsaaQuality) = 0;
    
    virtual void Draw(
        ID3D12GraphicsCommandList* cmdList,
        CD3DX12_GPU_DESCRIPTOR_HANDLE hGpuHandler,
        UINT srvHeapSize,
        UINT objCBByteSize,
        UINT matCBByteSize,
        UINT passCBByteSize,
        ID3D12Resource* objectCB,
        ID3D12Resource* matCB,
        ID3D12Resource* passCB,
        const PassConstants& passValue,
        ID3D12Resource* OutColorRenderTarget,
        D3D12_CPU_DESCRIPTOR_HANDLE OutColorRenderTargetView,
        D3D12_CPU_DESCRIPTOR_HANDLE OutDepthStentilView
        ) = 0;

public:
    virtual void AddSubPass(std::shared_ptr<Pass> subPass); 

protected:
    virtual void DrawRenderItem(
        ID3D12GraphicsCommandList* cmdList,
        CD3DX12_GPU_DESCRIPTOR_HANDLE hGpuHandler,
        UINT srvHeapSize,
        UINT objCBByteSize,
        UINT matCBByteSize,
        ID3D12Resource* objectCB,
        ID3D12Resource* matCB,
        const std::vector<RenderItem*>& ritems);

protected:
    std::vector<RenderItem*> mRenderItems;
    ComPtr<ID3D12PipelineState> mPso;

protected:
    std::vector<std::shared_ptr<Pass>> mSubPass;
};


